
import br.com.fiap.modelo.Satisfacao;
import java.io.IOException;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet(urlPatterns="/processarSatisfacao")
public class ProcessarSatisfacao extends HttpServlet{

    private EntityManagerFactory fabricaEntityManager;
    public void init() throws ServletException{
        fabricaEntityManager = Persistence.createEntityManagerFactory("sistemaWeb");
    }
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Satisfacao satisfacao = new Satisfacao();
        satisfacao.setNome(req.getParameter("comentario"));
        satisfacao.setComentario(req.getParameter("comentario"));
        EntityManager motor = fabricaEntityManager.createEntityManager();
        motor.getTransaction().begin();
        motor.persist(satisfacao);
        motor.getTransaction().commit();
        
    }
    
    

    
}